Please remember this is a work in progress. Home » Getting Started

Getting Started

 

Server Controller Overview

 

The Server Controller unit is were you can control general aspects of your Web Application, as for example, if you want to use compression, the Templates folder, how your application reacts if your user is using an unsupported browser, like IE6,among other several things.

The Server Controller is also responsible for creating user session instances, through the OnNewSession event, which is triggered when a new user connects to your web application.

In general, you do not need to add code to the server controller, except if you need custom control of a specific aspect of your application. A good reason for customizing the Server Controller is preparing your application to support Search Engines, like Goole or Yahoo. See Server Controller class reference for more information.

When your application is running, you have only one instance of the Server Controller class and the Server Controller will always be active, even if no user is connected to the application. You don't need to worry about creating/destroying the Server Controller instance, as this is handled automatically by IntraWeb for you.

For a description of the Server Controller properties, method and events, please check the Server Controller class description.

How to access the Server Controller instance in your code

In some parts of your application, you may need to access the Server Controller to check and use certain property values or call some method. The easiest way to access the Server Controller is using a function available in the Server Controller unit. You need to include the unit ServerController in the uses clause of the unit you want to access the Server Controller instance, as for example, your IWForms.

  1. function IWServerController: TIWServerController;
  2. begin
  3.   Result := TIWServerController(GServerController);
  4. end;

After you have added the ServerController unit to your uses clause, you simply access the Server Controller instance using the IWServerController function.

  1. procedure TfrmCustomers.IWLink1Click(Sender: TObject);
  2. var
  3.   xReport: TStringList;
  4.   xNomeArquivo: string;
  5. begin
  6.   xReport := UserSession.DM.ReportCustomerOrders(fCustomerID);
  7.   try
  8.     xNomeArquivo := IWServerController.UserCacheDir + UserSession.DM.RandomName + '.txt';
  9.     xReport.SaveToFile(xNomeArquivo);
  10.     WebApplication.SendFile(xNomeArquivo, True, '', 'Customer Report ' +
  11.       UserSession.DM.Customers.Dataset.FieldByName('CustNo').AsString + '.txt');
  12.   finally
  13.     FreeAndNil(xReport);
  14.   end;
  15. end;
  16.  
  17. initialization
  18.   TIWURLMap.Add('/Customer/', 'index.html', TfrmCustomers);
  19.  
  20. end.

 

Terms of Use | Privacy Statement © 2002 - 2024 Atozed Software